package com.desire.test;

import java.util.concurrent.TimeUnit;

/**
 * @author desire
 */
public class _39_线程2 {
    public static void main(String[] args) {
        Thread t1 = new Thread((() -> {
            try {
                TimeUnit.SECONDS.sleep(1);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
            System.out.println(Thread.currentThread().getName());
            System.out.println("次线程执行级别 " + Thread.currentThread().getPriority());
        }));

        // 线程的级别默认为 5
        t1.setName("次线程");
        t1.setPriority(10);
        //Thread.MAX_PRIORITY 10
        //Thread.MIN_PRIORITY 1
        //Thread.NORM_PRIORITY 5
        t1.start();


        // 设置主线程

        Thread mainThread = new Thread((() -> {
            try {
                TimeUnit.SECONDS.sleep(2);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
            System.out.println(Thread.currentThread().getName());
            System.out.println("主线程执行级别 " + Thread.currentThread().getPriority());
        }), "主线程");

        mainThread.start();
    }
}
